package com.mfdm.gui.wizards;

import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;

import com.mfdm.gui.utils.ColorAndFontUtils;

public class AddNewSongContentWizardPage extends WizardPage {

	private static final String ADD_SONG_CONTENT = "Add song content";
	
	private static final RGB BACKGROUND = new RGB(240, 245, 255);
	
	private static final RGB BACKGROUND2 = new RGB(230, 245, 255);
	
	private Text m_text;	

	
	protected AddNewSongContentWizardPage(String pageName) {
		super(pageName);
		setTitle(ADD_SONG_CONTENT);
	}

	@Override
	public void createControl(Composite parent) {
		
		parent.setBackground(new Color(this.getShell().getDisplay(), BACKGROUND));
		
		Composite container = new Composite(parent, SWT.NONE);
		container.setBackground(new Color(this.getShell().getDisplay(), BACKGROUND));
		container.setLayout(new GridLayout(5, false));		
		
		GridData gridDataToComposite1 = new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false);
		gridDataToComposite1.horizontalSpan = 2;
		
		Composite songInformationComposite = new Composite(container, SWT.NONE);
		songInformationComposite.setBackground(new Color(this.getShell().getDisplay(), BACKGROUND));

		songInformationComposite.setLayout(new GridLayout(2, false));
		songInformationComposite.setLayoutData(gridDataToComposite1);
		
		Label label = new Label(songInformationComposite, SWT.BOLD);
		label.setText("Song name: ");		
		Text songNameText = new Text(songInformationComposite, SWT.BORDER);
		songNameText.setText("Name of the song");
		
		Label label2 = new Label(songInformationComposite, SWT.BOLD);
		label2.setText("Author: ");
		Text authorText = new Text(songInformationComposite, SWT.BORDER);
		authorText.setText("The author");
		
		Label label3 = new Label(songInformationComposite, SWT.BOLD);
		label3.setText("Type: ");
		
		Combo comboType = new Combo(songInformationComposite, SWT.NONE);
		comboType.add("POP");
		comboType.add("ROCK");
		
		Label label4 = new Label(songInformationComposite, SWT.NONE);
		label4.setText("Melody: ");
		
		Combo combo = new Combo(songInformationComposite, SWT.NONE);
		combo.add("Slow");
		combo.add("Boleroooooooooooooooooo");		
		
		GridData gridDataToComposite2 = new GridData(GridData.FILL, GridData.FILL, true, true);
		gridDataToComposite2.horizontalSpan = 3;
		
		Composite songContentComposite = new Composite(container, SWT.NONE);
		songContentComposite.setBackground(new Color(this.getShell().getDisplay(), BACKGROUND2));

		songContentComposite.setLayout(new GridLayout());
		songContentComposite.setLayoutData(gridDataToComposite2);
		
		m_text = new Text(songContentComposite, SWT.MULTI|SWT.WRAP|SWT.V_SCROLL);
		GridData gridData2 = new GridData(GridData.FILL, GridData.FILL, true, true);
		m_text.setLayoutData(gridData2);
		m_text.setFont(ColorAndFontUtils.getDefaultTextFont(this.getShell()));
		
		setControl(container);
	}
	
	@Override
	public IWizardPage getNextPage() {
		if (null == m_text || m_text.getText() == null || m_text.getText().equals("")) {
			return super.getNextPage();
		} else {
			
			
			AddChordToSongWizardPage addChordToSongWizardPage = (AddChordToSongWizardPage) super.getNextPage();		
			addChordToSongWizardPage.showContents(m_text.getText());
			return addChordToSongWizardPage;
		}		
	}
}
